package com.lizhi.yun.base.task;/**
 * @program: sfrobot-html
 * @name MultithreadScheduleTask
 * @description: 多线程定时任务
 * @author: lizhi
 * @create: 2020-04-23 11:38
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 *@program: sfrobot-html
 *@name MultithreadScheduleTask
 *@description: 多线程定时任务
 *@author: lizhi
 *@create: 2020-04-23 11:38
 */
@Slf4j
@Component  //用于对那些比较中立的类进行注释；
@EnableScheduling // 开启定时任务
@EnableAsync  //开启多线程
public class MultithreadScheduleTask {

//    @Async
//    @Scheduled(cron = "0/5 * * * * ?")
    public void uploadDateTick(){
        log.info("******上传患者信息开始******");
    }

//    @Async
//    @Scheduled(cron = "0/10 * * * * ?")
    public void second() {
        System.out.println("第二个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
        System.out.println();
    }
}
